<script type="text/JavaScript">
function checkform() {
	d=document.registrationForm;
	if (d.username.value == "" || d.fname.value == "" || d.lname.value == "" || d.dob.value == "" || d.email.value == "" || d.password1.value == ""|| d.password2.value == "") {
		alert("Please complete all required fields.");
		return false;
	}
	if (d.password1.value != d.password2.value) {
		alert("Please check that the Password and Confirm Password fields match.");
		return false;
	}
	//http://www.javascriptkit.com/script/script2/validatedate.shtml
	if (!checkdob(d.dob.value)) {
		alert("Please check you have entered your Date of Birth in the correct format (DD/MM/YYYY).");
		return false;
	}
	if (!checkemail(d.email.value)) {
		alert("Please enter a valid email address.");
		return false;
	}
	
	return true;
}

function checkdob(dob) {
	validformat=/^\d{2}\/\d{2}\/\d{4}$/
	if (!validformat.test(dob)) {
		return false;
	}
	return true;
}

function checkemail(email) {
	validformat=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (!validformat.test(email)) {
		return false;
	}
	return true;
}

</script>